﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
using Windows.UI.StartScreen;

namespace VivendoByteToolkit.Tile
{
    public static class TileHelper
    {
        static TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();

        public static bool UpdateTileWithNumber(int number)
        {
            try
            {
                string badge = String.Format("<badge value=\"{0}\"/>", number);
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(badge);
                BadgeNotification badgeNotification = new BadgeNotification(xmlDoc);
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeNotification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public async static Task<bool> CreateSecondaryTile(string toastId, string shortName, string displayName, TileOptions options, string logo)
        {
            try
            {
                if (!logo.StartsWith("ms-appx:///"))
                {
                    logo = string.Concat("ms-appx:///", logo);
                }

                SecondaryTile secondaryTile = new SecondaryTile(toastId, shortName, displayName, new Uri(logo, UriKind.RelativeOrAbsolute), TileSize.Square150x150);
                await secondaryTile.RequestCreateAsync();
                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool IsPinned(string toastId)
        {
            return SecondaryTile.Exists(toastId);
        }

        public async static Task<bool> DeleteSecondaryTile(string toastId)
        {
            try
            {
                if (IsPinned(toastId))
                {
                    var tileToBeDeleted = new Windows.UI.StartScreen.SecondaryTile(toastId);
                    await tileToBeDeleted.RequestDeleteAsync();
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileSquareBlock(string largeText, string smallText)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Block);
                XmlNodeList toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(largeText));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(smallText));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileSquareText01(string header, string firstRow, string secondRow, string thirdRow)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text01);
                XmlNodeList toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(firstRow));
                toastTextElements[2].AppendChild(tileXml.CreateTextNode(secondRow));
                toastTextElements[3].AppendChild(tileXml.CreateTextNode(thirdRow));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileSquareText02(string header, string content)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text02);
                XmlNodeList toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(content));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileSquareText03(string firstRow, string secondRow, string thirdRow, string fourthRow)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text03);
                XmlNodeList toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(firstRow));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(secondRow));
                toastTextElements[2].AppendChild(tileXml.CreateTextNode(thirdRow));
                toastTextElements[3].AppendChild(tileXml.CreateTextNode(fourthRow));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileSquareText04(string longContent)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text04);
                XmlNodeList toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(longContent));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileSquareImage(string image)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Image);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileSquarePeekImageAndText01(string image, string header, string firstRow, string secondRow, string thirdRow)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText01);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(firstRow));
                toastTextElements[2].AppendChild(tileXml.CreateTextNode(secondRow));
                toastTextElements[3].AppendChild(tileXml.CreateTextNode(thirdRow));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileSquarePeekImageAndText02(string image, string header, string content)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText02);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(content));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileSquarePeekImageAndText03(string image, string firstRow, string secondRow, string thirdRow, string fourthRow)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText03);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(firstRow));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(secondRow));
                toastTextElements[2].AppendChild(tileXml.CreateTextNode(thirdRow));
                toastTextElements[3].AppendChild(tileXml.CreateTextNode(fourthRow));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileSquarePeekImageAndText04(string image, string content)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText04);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(content));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideText01(string header, string firstRow, string secondRow, string thirdRow, string fourthRow)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text01);
                var toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(firstRow));
                toastTextElements[2].AppendChild(tileXml.CreateTextNode(secondRow));
                toastTextElements[3].AppendChild(tileXml.CreateTextNode(thirdRow));
                toastTextElements[4].AppendChild(tileXml.CreateTextNode(fourthRow));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideText02(string header, string firstRow, string secondRow, string thirdRow, string fourthRow, string fifthRow, string sixthRow, string seventhRow, string eighthRow)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text02);
                var toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(firstRow));
                toastTextElements[2].AppendChild(tileXml.CreateTextNode(secondRow));
                toastTextElements[3].AppendChild(tileXml.CreateTextNode(thirdRow));
                toastTextElements[4].AppendChild(tileXml.CreateTextNode(fourthRow));
                toastTextElements[5].AppendChild(tileXml.CreateTextNode(fifthRow));
                toastTextElements[6].AppendChild(tileXml.CreateTextNode(sixthRow));
                toastTextElements[7].AppendChild(tileXml.CreateTextNode(seventhRow));
                toastTextElements[8].AppendChild(tileXml.CreateTextNode(eighthRow));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideText03(string content)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text03);
                var toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(content));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideText04(string content)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text04);
                var toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(content));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideText05(string firstRow, string secondRow, string thirdRow, string fourthRow, string fifthRow)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text05);
                var toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(firstRow));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(secondRow));
                toastTextElements[2].AppendChild(tileXml.CreateTextNode(thirdRow));
                toastTextElements[3].AppendChild(tileXml.CreateTextNode(fourthRow));
                toastTextElements[4].AppendChild(tileXml.CreateTextNode(fifthRow));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideText06(string firstRow, string secondRow, string thirdRow, string fourthRow, string fifthRow, string sixthRow, string seventhRow, string eighthRow, string ninthRow, string tenthRow)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text06);
                var toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(firstRow));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(secondRow));
                toastTextElements[2].AppendChild(tileXml.CreateTextNode(thirdRow));
                toastTextElements[3].AppendChild(tileXml.CreateTextNode(fourthRow));
                toastTextElements[4].AppendChild(tileXml.CreateTextNode(fifthRow));
                toastTextElements[5].AppendChild(tileXml.CreateTextNode(sixthRow));
                toastTextElements[6].AppendChild(tileXml.CreateTextNode(seventhRow));
                toastTextElements[7].AppendChild(tileXml.CreateTextNode(eighthRow));
                toastTextElements[8].AppendChild(tileXml.CreateTextNode(ninthRow));
                toastTextElements[9].AppendChild(tileXml.CreateTextNode(tenthRow));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideText07(string header, string label1, string content1, string label2, string content2, string label3, string content3, string label4, string content4)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text07);
                var toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(label1));
                toastTextElements[2].AppendChild(tileXml.CreateTextNode(content1));
                toastTextElements[3].AppendChild(tileXml.CreateTextNode(label2));
                toastTextElements[4].AppendChild(tileXml.CreateTextNode(content2));
                toastTextElements[5].AppendChild(tileXml.CreateTextNode(label3));
                toastTextElements[6].AppendChild(tileXml.CreateTextNode(content3));
                toastTextElements[7].AppendChild(tileXml.CreateTextNode(label4));
                toastTextElements[8].AppendChild(tileXml.CreateTextNode(content4));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideText08(string label1, string content1, string label2, string content2, string label3, string content3, string label4, string content4, string label5, string content5)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text08);
                var toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(label1));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(content1));
                toastTextElements[2].AppendChild(tileXml.CreateTextNode(label2));
                toastTextElements[3].AppendChild(tileXml.CreateTextNode(content2));
                toastTextElements[4].AppendChild(tileXml.CreateTextNode(label3));
                toastTextElements[5].AppendChild(tileXml.CreateTextNode(content3));
                toastTextElements[6].AppendChild(tileXml.CreateTextNode(label4));
                toastTextElements[7].AppendChild(tileXml.CreateTextNode(content4));
                toastTextElements[8].AppendChild(tileXml.CreateTextNode(label5));
                toastTextElements[9].AppendChild(tileXml.CreateTextNode(content5));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideText09(string header, string content)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text09);
                var toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(content));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideText10(string header, string label1, string content1, string label2, string content2, string label3, string content3, string label4, string content4)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text10);
                var toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(label1));
                toastTextElements[2].AppendChild(tileXml.CreateTextNode(content1));
                toastTextElements[3].AppendChild(tileXml.CreateTextNode(label2));
                toastTextElements[4].AppendChild(tileXml.CreateTextNode(content2));
                toastTextElements[5].AppendChild(tileXml.CreateTextNode(label3));
                toastTextElements[6].AppendChild(tileXml.CreateTextNode(content3));
                toastTextElements[7].AppendChild(tileXml.CreateTextNode(label4));
                toastTextElements[8].AppendChild(tileXml.CreateTextNode(content4));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideText11(string label1, string content1, string label2, string content2, string label3, string content3, string label4, string content4, string label5, string content5)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text11);
                var toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(label1));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(content1));
                toastTextElements[2].AppendChild(tileXml.CreateTextNode(label2));
                toastTextElements[3].AppendChild(tileXml.CreateTextNode(content2));
                toastTextElements[4].AppendChild(tileXml.CreateTextNode(label3));
                toastTextElements[5].AppendChild(tileXml.CreateTextNode(content3));
                toastTextElements[6].AppendChild(tileXml.CreateTextNode(label4));
                toastTextElements[7].AppendChild(tileXml.CreateTextNode(content4));
                toastTextElements[8].AppendChild(tileXml.CreateTextNode(label5));
                toastTextElements[9].AppendChild(tileXml.CreateTextNode(content5));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideImage(string image)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Image);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideImageCollection(string image1, string image2, string image3, string image4, string image5)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150ImageCollection);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image1;
                toastTextElements[1].Attributes.GetNamedItem("src").NodeValue = image2;
                toastTextElements[2].Attributes.GetNamedItem("src").NodeValue = image3;
                toastTextElements[3].Attributes.GetNamedItem("src").NodeValue = image4;
                toastTextElements[4].Attributes.GetNamedItem("src").NodeValue = image5;

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideImageAndText01(string image, string content)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150ImageAndText01);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(content));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideImageAndText02(string image, string firstRow, string secondRow)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150ImageAndText02);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(firstRow));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(secondRow));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideBlockAndText01(string firstRow, string secondRow, string thirdRow, string fourthRow, string bigContent, string subtitle)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150BlockAndText01);
                var toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(firstRow));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(secondRow));
                toastTextElements[2].AppendChild(tileXml.CreateTextNode(thirdRow));
                toastTextElements[3].AppendChild(tileXml.CreateTextNode(fourthRow));
                toastTextElements[4].AppendChild(tileXml.CreateTextNode(bigContent));
                toastTextElements[5].AppendChild(tileXml.CreateTextNode(subtitle));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideBlockAndText02(string content, string bigContent, string subtitle)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150BlockAndText02);
                var toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(content));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(bigContent));
                toastTextElements[2].AppendChild(tileXml.CreateTextNode(subtitle));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideSmallImageAndText01(string image, string content)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150SmallImageAndText01);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(content));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideSmallImageAndText02(string image, string header, string firstRow, string secondRow, string thirdRow, string fourthRow)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150SmallImageAndText02);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(firstRow));
                toastTextElements[2].AppendChild(tileXml.CreateTextNode(secondRow));
                toastTextElements[3].AppendChild(tileXml.CreateTextNode(thirdRow));
                toastTextElements[4].AppendChild(tileXml.CreateTextNode(fourthRow));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideSmallImageAndText03(string image, string content)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150SmallImageAndText03);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(content));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideSmallImageAndText04(string image, string header, string content)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150SmallImageAndText04);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(content));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWideSmallImageAndText05(string image, string header, string content)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150SmallImageAndText05);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(content));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWidePeekImageCollection01(string bigImage, string image1, string image2, string image3, string image4, string header, string content)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImageCollection01);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = bigImage;
                toastTextElements[1].Attributes.GetNamedItem("src").NodeValue = image1;
                toastTextElements[2].Attributes.GetNamedItem("src").NodeValue = image2;
                toastTextElements[3].Attributes.GetNamedItem("src").NodeValue = image3;
                toastTextElements[4].Attributes.GetNamedItem("src").NodeValue = image4;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(content));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWidePeekImageCollection02(string bigImage, string image1, string image2, string image3, string image4, string header, string firstRow, string secondRow, string thirdRow, string fourthRow)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImageCollection02);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = bigImage;
                toastTextElements[1].Attributes.GetNamedItem("src").NodeValue = image1;
                toastTextElements[2].Attributes.GetNamedItem("src").NodeValue = image2;
                toastTextElements[3].Attributes.GetNamedItem("src").NodeValue = image3;
                toastTextElements[4].Attributes.GetNamedItem("src").NodeValue = image4;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(firstRow));
                toastTextElements[2].AppendChild(tileXml.CreateTextNode(secondRow));
                toastTextElements[3].AppendChild(tileXml.CreateTextNode(thirdRow));
                toastTextElements[4].AppendChild(tileXml.CreateTextNode(fourthRow));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWidePeekImageCollection03(string bigImage, string image1, string image2, string image3, string image4, string header)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImageCollection03);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = bigImage;
                toastTextElements[1].Attributes.GetNamedItem("src").NodeValue = image1;
                toastTextElements[2].Attributes.GetNamedItem("src").NodeValue = image2;
                toastTextElements[3].Attributes.GetNamedItem("src").NodeValue = image3;
                toastTextElements[4].Attributes.GetNamedItem("src").NodeValue = image4;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWidePeekImageCollection04(string bigImage, string image1, string image2, string image3, string image4, string content)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImageCollection04);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = bigImage;
                toastTextElements[1].Attributes.GetNamedItem("src").NodeValue = image1;
                toastTextElements[2].Attributes.GetNamedItem("src").NodeValue = image2;
                toastTextElements[3].Attributes.GetNamedItem("src").NodeValue = image3;
                toastTextElements[4].Attributes.GetNamedItem("src").NodeValue = image4;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(content));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWidePeekImageCollection05(string bigImage, string image1, string image2, string image3, string image4, string rearImage, string header, string content)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImageCollection05);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = bigImage;
                toastTextElements[1].Attributes.GetNamedItem("src").NodeValue = image1;
                toastTextElements[2].Attributes.GetNamedItem("src").NodeValue = image2;
                toastTextElements[3].Attributes.GetNamedItem("src").NodeValue = image3;
                toastTextElements[4].Attributes.GetNamedItem("src").NodeValue = image4;
                toastTextElements[5].Attributes.GetNamedItem("src").NodeValue = rearImage;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(content));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWidePeekImageCollection06(string bigImage, string image1, string image2, string image3, string image4, string rearImage, string header)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImageCollection06);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = bigImage;
                toastTextElements[1].Attributes.GetNamedItem("src").NodeValue = image1;
                toastTextElements[2].Attributes.GetNamedItem("src").NodeValue = image2;
                toastTextElements[3].Attributes.GetNamedItem("src").NodeValue = image3;
                toastTextElements[4].Attributes.GetNamedItem("src").NodeValue = image4;
                toastTextElements[5].Attributes.GetNamedItem("src").NodeValue = rearImage;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWidePeekImageAndText01(string image, string content)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImageAndText01);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(content));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWidePeekImageAndText02(string image, string firstRow, string secondRow, string thirdRow, string fourthRow, string fifthRow)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImageAndText02);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(firstRow));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(secondRow));
                toastTextElements[2].AppendChild(tileXml.CreateTextNode(thirdRow));
                toastTextElements[3].AppendChild(tileXml.CreateTextNode(fourthRow));
                toastTextElements[4].AppendChild(tileXml.CreateTextNode(fifthRow));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWidePeekImage01(string image, string header, string content)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImage01);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(content));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWidePeekImage02(string image, string header, string firstRow, string secondRow, string thirdRow, string fourthRow)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImage02);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(firstRow));
                toastTextElements[2].AppendChild(tileXml.CreateTextNode(secondRow));
                toastTextElements[3].AppendChild(tileXml.CreateTextNode(thirdRow));
                toastTextElements[4].AppendChild(tileXml.CreateTextNode(fourthRow));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWidePeekImage03(string image, string header)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImage03);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWidePeekImage04(string image, string content)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImage04);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(content));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWidePeekImage05(string image, string rearImage, string header, string content)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImage05);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;
                toastTextElements[1].Attributes.GetNamedItem("src").NodeValue = rearImage;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));
                toastTextElements[1].AppendChild(tileXml.CreateTextNode(content));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool UpdateTileWidePeekImage06(string image, string rearImage, string header)
        {
            try
            {
                XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImage06);
                var toastTextElements = tileXml.GetElementsByTagName("image");
                toastTextElements[0].Attributes.GetNamedItem("src").NodeValue = image;
                toastTextElements[1].Attributes.GetNamedItem("src").NodeValue = rearImage;

                toastTextElements = tileXml.GetElementsByTagName("text");
                toastTextElements[0].AppendChild(tileXml.CreateTextNode(header));

                TileNotification notification = new TileNotification(tileXml);
                tileUpdater.Update(notification);

                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}